package pe.com.bbva.modpre.utileria;

import java.io.ByteArrayOutputStream;
import java.util.List;

public class ReporteCSV {
	public static ByteArrayOutputStream exportarCSV(String[] cabecera,String titulo,List<String[]> filasTablas){
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		StringBuilder stringBuilder=new StringBuilder();
		String cabeceraCSV="";
		for (String stringCabecera : cabecera) {
			cabeceraCSV=cabeceraCSV+stringCabecera+",";
		}
		stringBuilder.append(cabeceraCSV+"\n");
		for (String[] stringFilas : filasTablas) {
			String filaN="";
			for (String string : stringFilas) {
				filaN=filaN+"\""+string+"\""+",";
			}
			stringBuilder.append(filaN+"\n");
		}
		
		byte[] bytes=stringBuilder.toString().getBytes();
		
		outputStream.write(bytes, 0, bytes.length);
		
		return outputStream;
	}

}
